package com.ply.config;

import com.ply.filter.AdminTokenFilter;
import com.ply.filter.TokenFilter;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

@SpringBootConfiguration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<TokenFilter> filterOneRegister() {
        FilterRegistrationBean<TokenFilter> filterRegistrationBean = new FilterRegistrationBean<>();
        filterRegistrationBean.setFilter(new TokenFilter());
        filterRegistrationBean.addUrlPatterns("/user/*");
//		filterRegistrationBean.setOrder(100);
//
//
//
        return filterRegistrationBean;
    }

    @Bean
    public FilterRegistrationBean<AdminTokenFilter> filterTowRegister() {
        FilterRegistrationBean<AdminTokenFilter> filterFilterRegistrationBean = new FilterRegistrationBean<>();
        filterFilterRegistrationBean.setFilter(new AdminTokenFilter());
        filterFilterRegistrationBean.addUrlPatterns("/admin/*");
//		filterRegistrationBean.setOrder(100);

        return filterFilterRegistrationBean;
    }
}